//路由配置信息
export default [
    {
        name: 'home',
        path: "/home",
        component: ()=>import('@/pages/Home'), //路由懒加载
        meta: {
            isShowFooter: true,
            needUserInfo: false
        }
    },
    {
        name: 'search',
        path: "/search/:keyword?",
        component: ()=>import('@/pages/Search'),//路由懒加载
        meta: {
            isShowFooter: true,
            needUserInfo: false

        },

    },
    {
        name: 'login',
        path: "/login",
        component: ()=>import('@/pages/Login'),
        meta: {
            isShowFooter: false,
            needUserInfo: false
        }
    },
    {
        name: 'register',
        path: "/register",
        component: ()=>import('@/pages/Register'),
        meta: {
            isShowFooter: false,
            needUserInfo: false
        }
    },
    {
        name: 'detail',
        path: "/detail/:skuid",
        component:  ()=>import("@/pages/Detail"),
        meta: {
            isShowFooter: true,
            needUserInfo: false

        }
    },
    {
        name: 'addcartsuccess',
        path: "/addcartsuccess",
        component:  ()=>import("@/pages/AddCartSuccess"),
        meta: {
            isShowFooter: true,
            needUserInfo: false

        }
    },
    {
        name: 'shopcart',
        path: "/shopcart",
        component:  ()=>import("@/pages/ShopCart"),
        meta: {
            isShowFooter: true,
            needUserInfo: false

        }
    },
    {
        name: 'trade',
        path: "/trade",
        component:  ()=>import("@/pages/Trade"),
        meta: {
            isShowFooter: true,
            needUserInfo: true
        },
        //路由独享守卫
        beforeEnter(to, from, next) {
            //要去交易页页面必须从购物车跳转
            if (from.path == '/shopcart') {
                next()
            } else {
               next(false)
            }
        }
    },
    {
        name: 'pay',
        path: "/pay",
        component:  ()=>import("@/pages/Pay"),
        meta: {
            isShowFooter: true,
            needUserInfo: true
        },
        //路由独享守卫
        beforeEnter(to, from, next) {
            //要去交易页页面必须从购物车跳转
            if (from.path == '/trade') {
                next()
            } else {
               next(false)
            }
        }
    },
    {  
        name: 'paysuccess',
        path: "/paysuccess",
        component:  ()=>import("@/pages/PaySuccess"),
        meta: {
            isShowFooter: true,
            needUserInfo: true
        },
        //路由独享守卫
        beforeEnter(to, from, next) {
            //要去交易页页面必须从购物车跳转
            if (from.path == '/pay') {
                next()
            } else {
               next(false)
            }
        }
    },
    {
        name: 'myorder',
        path: "/myorder",
        component:  ()=>import("@/pages/MyOrder"),
        meta: {
            isShowFooter: true,
            needUserInfo: true
        }
    },
    


    //重定向，项目初始页面定位到首页
    {
        path: '*',
        redirect: '/home'
    }

]